package com.overlord.im.commons.constant;

import java.util.stream.Stream;

/**
 * @author wuwei
 * @className MsgType
 * @description
 * @date 2020/5/9 11:26
 **/
public enum MsgType {
    /**
     * 聊天消息
     */
    CHAT(0),

    /**
     * 群组聊天
     */
    GROUP_CHAT(1),

    /**
     * 系统消息
     */
    SYSTEM(2),

    ;

    int code;

    MsgType(int code) {
        this.code = code;
    }

    public static MsgType fromCode(int code) {
        return Stream.of(values()).filter(t -> t.code == code).findFirst().orElseThrow(IllegalArgumentException::new);
    }

    public int getCode() {
        return code;
    }
}
